<html>
<head><meta charset="utf-8"><title>Deny unaligned references? · edition 2021 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/index.html">edition 2021</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html">Deny unaligned references?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221542285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221542285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221542285">(Jan 04 2021 at 16:07)</a>:</h4>
<p>It just occurred to me that maybe, with this edition, we could finally tackle <a href="https://github.com/rust-lang/rust/issues/27060">https://github.com/rust-lang/rust/issues/27060</a> by making references to packed fields a hard error.<br>
This would require stabilizing <a href="https://github.com/rust-lang/rust/issues/73394">https://github.com/rust-lang/rust/issues/73394</a> first, which seems totally feasible.</p>



<a name="221542573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221542573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221542573">(Jan 04 2021 at 16:09)</a>:</h4>
<p>/me is still working on that rustdoc bug <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="221542645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221542645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221542645">(Jan 04 2021 at 16:09)</a>:</h4>
<p>I have a backup plan in case that doesn't get fixed in time though -- just move the macros to the crate root ;)</p>



<a name="221542752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221542752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221542752">(Jan 04 2021 at 16:10)</a>:</h4>
<p><span class="user-mention" data-user-id="248906">@cjgillot</span> how is <a href="https://github.com/rust-lang/rust/pull/80415">https://github.com/rust-lang/rust/pull/80415</a> coming?</p>



<a name="221547193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221547193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221547193">(Jan 04 2021 at 16:41)</a>:</h4>
<p>I added the test. Should be good to go. Is the test good enough for you ?</p>



<a name="221572629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221572629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221572629">(Jan 04 2021 at 19:57)</a>:</h4>
<p><span class="user-mention" data-user-id="248906">@cjgillot</span> that tests existing behavior so it's not doing much, but that's no big deal. I don't think you addressed petrochenkov's review though: <a href="https://github.com/rust-lang/rust/pull/80415#issuecomment-751699094">https://github.com/rust-lang/rust/pull/80415#issuecomment-751699094</a></p>



<a name="221579501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221579501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221579501">(Jan 04 2021 at 20:57)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Seems reasonable to me, as long as raw refs get stabilized in a timely fashion.</p>



<a name="221579534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221579534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221579534">(Jan 04 2021 at 20:57)</a>:</h4>
<p>We'd need some transition time, so they'd need to be stable <em>before</em> the edition release.</p>



<a name="221579621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221579621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221579621">(Jan 04 2021 at 20:58)</a>:</h4>
<p>And the current non-hard error about such references should point people to raw refs.</p>



<a name="221753586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/221753586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#221753586">(Jan 06 2021 at 10:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/268952-edition/topic/Deny.20unaligned.20references.3F/near/221579501">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> Seems reasonable to me, as long as raw refs get stabilized in a timely fashion.</p>
</blockquote>
<p>besides the rustdoc problem (which we can work around if needed, albeit at the cost of an API change), I think the only blocker here is <a href="#narrow/stream/219381-t-libs/topic/raw_ref.20macros">the naming problem</a>.</p>



<a name="222259151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259151">(Jan 11 2021 at 04:23)</a>:</h4>
<p>The rustdoc issue has been fixed on nightly :) <a href="https://doc.rust-lang.org/stable/std/ptr/macro.raw_const.html">https://doc.rust-lang.org/stable/std/ptr/macro.raw_const.html</a></p>
<p>Giant thank you to <span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> for pushing this through!</p>



<a name="222259161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259161">(Jan 11 2021 at 04:23)</a>:</h4>
<p>Err wait hold on, that's stable</p>



<a name="222259207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259207">(Jan 11 2021 at 04:24)</a>:</h4>
<p>That's weird...</p>



<a name="222259233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259233">(Jan 11 2021 at 04:25)</a>:</h4>
<p>I am confused</p>



<a name="222259330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259330">(Jan 11 2021 at 04:27)</a>:</h4>
<p>Looks like it's been in the right place all along (since 1.46, and I think that might have been when it was added).</p>



<a name="222259346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259346">(Jan 11 2021 at 04:27)</a>:</h4>
<p>(deleted)</p>



<a name="222259364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259364">(Jan 11 2021 at 04:28)</a>:</h4>
<p>Ok the issue is it was wrong in <code>core</code>, not in std</p>



<a name="222259613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222259613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222259613">(Jan 11 2021 at 04:34)</a>:</h4>
<p>Ah, that makes sense! It worked in <code>std</code> because it was a re-export I guess?</p>



<a name="222272925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222272925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222272925">(Jan 11 2021 at 09:02)</a>:</h4>
<p>Indeed</p>



<a name="222284455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222284455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222284455">(Jan 11 2021 at 11:15)</a>:</h4>
<p>Yay, thanks <span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> :)</p>



<a name="222284465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222284465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222284465">(Jan 11 2021 at 11:15)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/core/ptr/macro.raw_const.html">https://doc.rust-lang.org/nightly/core/ptr/macro.raw_const.html</a> shows that the fix worked :D</p>



<a name="222284560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/222284560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#222284560">(Jan 11 2021 at 11:16)</a>:</h4>
<p>stabilization PR is up at <a href="https://github.com/rust-lang/rust/pull/80886">https://github.com/rust-lang/rust/pull/80886</a></p>



<a name="227898583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Deny%20unaligned%20references%3F/near/227898583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F.html#227898583">(Feb 26 2021 at 08:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/268952-edition-2021/topic/Deny.20unaligned.20references.3F/near/221579621">said</a>:</p>
<blockquote>
<p>And the current non-hard error about such references should point people to raw refs.</p>
</blockquote>
<p>I am getting that ball rolling with <a href="https://github.com/rust-lang/rust/issues/82525">#82525</a> (making the non-hard error point to <a href="https://github.com/rust-lang/rust/issues/82523">#82523</a>, and also showing it inside unsafe blocks)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>